import QtQuick 2.0
import QtQuick.Controls 2.0

Item {
    id:bar
    width: 205
    height: 50

    //自定义信号
    //无参数信号 括号可省掉
    signal clickBar
    //带参数的信号
    signal indexChanged(int index)


    Row{
        anchors.fill: parent
        spacing: 5

        Rectangle{
            width: 100
            height: 50
            color:"#66ccff"

            MouseArea{
                anchors.fill: parent
                onPressed: {
                    parent.color = "#00aaff"
                }
                onReleased: {
                    parent.color = "#66ccff"
                    //发出自定义的信号
                    bar.clickBar()
                    bar.indexChanged(0)
                }
            }
            Text{
                anchors.centerIn: parent
                text: "首页"
            }
        }

        Rectangle{
            width: 100
            height: 50
            color:"#66ccff"

            MouseArea{
                anchors.fill: parent
                onPressed: {
                    parent.color = "#00aaff"
                }
                onReleased: {
                    parent.color = "#66ccff"
                    //发出自定义的信号
                    bar.clickBar()
                    bar.indexChanged(1)
                }
            }
            Text{
                anchors.centerIn: parent
                text: "我的"
            }
        }

    }
}
